﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ModularFixture.CApMFFixtureDesignerEmsHandler
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.Collections;
using System.Collections.ObjectModel;
using Tecnomatix.Engineering;
using Tecnomatix.Planning;


namespace DnProcessSimulateCommands.ModularFixture;

internal class CApMFFixtureDesignerEmsHandler
{
  internal CApMFFixtureDesignerEmsHandler()
  {
  }

  internal void ImportDataToCache(int internalId)
  {
    try
    {
      ITxPlanningObject objectByInternalId = new TxEmsGlobalServicesProvider().GetObjectByInternalId(internalId);
      TxObjectList txObjectList = new TxObjectList();
      ((Collection<ITxObject>) txObjectList).Add((ITxObject) objectByInternalId);
      TxEmsImportFieldsData importFieldsData = new TxEmsImportFieldsData();
      importFieldsData.Roots = txObjectList;
      ArrayList arrayList1 = new ArrayList();
      arrayList1.Add((object) this.GetConfigurationFieldsToCollect());
      arrayList1.Add((object) this.GetToolInstanceFieldsToCollect());
      arrayList1.Add((object) this.GetVariationFieldsToCollect());
      arrayList1.Add((object) this.GetToolPrototypeFieldsToCollect());
      arrayList1.Add((object) this.GetLayoutFieldsToCollect());
      ArrayList arrayList2 = new ArrayList();
      arrayList2.Add((object) this.GetConfigurationFieldsToTraverse());
      arrayList2.Add((object) this.GetToolInstanceFieldsToTraverse());
      arrayList2.Add((object) this.GetVariationFieldsToTraverse());
      importFieldsData.addFieldsToCollect(arrayList1);
      importFieldsData.addFieldsToTraverse(arrayList2);
      (TxApplication.ActiveDocument.PlatformGlobalServicesProvider as TxEmsGlobalServicesProvider).ImportFields((TxPlatformImportFieldsData) importFieldsData);
    }
    catch (Exception ex)
    {
    }
  }

  internal void ImportDataToCacheForSearchConditions(
    int internalId,
    ArrayList conditionsContainedInSolutions,
    ArrayList conditionsNotContainedInSolutions)
  {
    try
    {
      ITxPlanningObject objectByInternalId = new TxEmsGlobalServicesProvider().GetObjectByInternalId(internalId);
      TxObjectList txObjectList = new TxObjectList();
      ((Collection<ITxObject>) txObjectList).Add((ITxObject) objectByInternalId);
      TxEmsImportFieldsData importFieldsData = new TxEmsImportFieldsData();
      importFieldsData.Roots = txObjectList;
      ArrayList arrayList1 = new ArrayList();
      ArrayList arrayList2 = new ArrayList();
      foreach (CApMFSearchCondition containedInSolution in conditionsContainedInSolutions)
      {
        TxClassFieldsCollectionData forSearchCondition = this.GetFieldsToCollectForSearchCondition(containedInSolution);
        arrayList2.Add((object) forSearchCondition);
      }
      foreach (CApMFSearchCondition containedInSolution in conditionsNotContainedInSolutions)
      {
        TxClassFieldsCollectionData forSearchCondition = this.GetFieldsToCollectForSearchCondition(containedInSolution);
        arrayList2.Add((object) forSearchCondition);
      }
      ArrayList arrayList3 = new ArrayList();
      arrayList3.Add((object) this.GetConfigurationFieldsToTraverse());
      arrayList3.Add((object) this.GetToolInstanceFieldsToTraverse());
      arrayList3.Add((object) this.GetVariationFieldsToTraverse());
      importFieldsData.addFieldsToCollect(arrayList2);
      importFieldsData.addFieldsToTraverse(arrayList3);
      (TxApplication.ActiveDocument.PlatformGlobalServicesProvider as TxEmsGlobalServicesProvider).ImportFields((TxPlatformImportFieldsData) importFieldsData);
    }
    catch (Exception ex)
    {
    }
  }

  private TxClassFieldsTraversalData GetConfigurationFieldsToTraverse()
  {
    return new TxClassFieldsTraversalData()
    {
      ClassName = "UnitConfigurationPrototype",
      FieldNames = new ArrayList() { (object) "children" }
    };
  }

  private TxClassFieldsTraversalData GetVariationFieldsToTraverse()
  {
    return new TxClassFieldsTraversalData()
    {
      ClassName = "UnitConfigurationVarPrototype",
      FieldNames = new ArrayList() { (object) "children" }
    };
  }

  private TxClassFieldsTraversalData GetToolInstanceFieldsToTraverse()
  {
    return new TxClassFieldsTraversalData()
    {
      ClassName = "ToolInstance",
      FieldNames = new ArrayList()
      {
        (object) "prototype",
        (object) "layout"
      }
    };
  }

  private TxClassFieldsCollectionData GetFieldsToCollectForSearchCondition(
    CApMFSearchCondition condition)
  {
    return new TxClassFieldsCollectionData()
    {
      ClassName = condition.ObjectType,
      FieldNames = new ArrayList()
      {
        (object) condition.Attribute
      }
    };
  }

  private TxClassFieldsCollectionData GetConfigurationFieldsToCollect()
  {
    return new TxClassFieldsCollectionData()
    {
      ClassName = "UnitConfigurationPrototype",
      FieldNames = new ArrayList()
      {
        (object) "children",
        (object) "Ex_ClassDef",
        (object) "raiser"
      }
    };
  }

  private TxClassFieldsCollectionData GetVariationFieldsToCollect()
  {
    return new TxClassFieldsCollectionData()
    {
      ClassName = "UnitConfigurationVarPrototype",
      FieldNames = new ArrayList()
      {
        (object) "children",
        (object) "Ex_ClassDef"
      }
    };
  }

  private TxClassFieldsCollectionData GetToolInstanceFieldsToCollect()
  {
    return new TxClassFieldsCollectionData()
    {
      ClassName = "PmToolInstance",
      FieldNames = new ArrayList()
      {
        (object) "prototype",
        (object) "IntermediateUnitPlacementPoint",
        (object) "layout",
        (object) "BasicUnitStructure",
        (object) "PlacementOrigin"
      }
    };
  }

  private TxClassFieldsCollectionData GetLayoutFieldsToCollect()
  {
    return new TxClassFieldsCollectionData()
    {
      ClassName = "Layout",
      FieldNames = new ArrayList()
      {
        (object) "location",
        (object) "rotation"
      }
    };
  }

  private TxClassFieldsCollectionData GetToolPrototypeFieldsToCollect()
  {
    return new TxClassFieldsCollectionData()
    {
      ClassName = "ToolPrototype",
      FieldNames = new ArrayList()
      {
        (object) "Modfix_ConnectingPart",
        (object) "Ex_ClassDef",
        (object) "weight"
      }
    };
  }
}
